package com.bs.bookshare.common;

import java.util.HashMap;
import java.util.Map;

public class Resp {

    public int code;
    public String message;
    private Map<String,Object> data;

    public Resp(int code, String message) {
        this.code = code;
        this.message = message;
        this.data = new HashMap<>();//响应数据封装在这里
    }

    public static Resp ok(){//成功的响应
        Resp resp = new Resp(10086, "ok");
        return resp;
    }

    public static Resp notok(){//失败的响应
        Resp resp = new Resp(10086, "not ok");
        return resp;
    }

    public Resp data(String key,Object value){
        this.data.put(key, value);
        return this;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}
